<template>
  <div class="process-monitoring-box">
      <commpVxeTable
       :config="dataTableConfig"
       :columns="columnsVxe"
       :formItem="formItem"
       @checkboxChange="checkboxChange"
       ref="acceptanceRegistrationRef"
       @searchEvent="searchEvent"
       @resetEvent="resetEvent"
       >
          <template v-slot:operation_ffsrmc="{row}" data-desc="姓名">
            <span style="padding-right: 21;" v-if="row.fusermc&&row.fusermc.length == 2">
                <span v-for="(trem,tI) in row.fusermc.split('')" :key="tI" >
                    {{trem}}
                    <span v-if="tI+1 !== row.fusermc.split('').length">&nbsp;&nbsp;</span>
                </span>
            </span>
            <span style="padding-right: 21;" v-else>{{ row.fusermc }}</span>
          </template>
          <template v-slot:name_fzjjssj="{row}">
              <span>{{row.fzjkssj}}至{{row.fzjjssj}}</span>
          </template>
          <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
              <a-form layout="inline" class="search-form" >
                  <a-form-item >
                      <a-button class="blue-btn" type="primary" @click="reviseClick(row)">办理</a-button>
                  </a-form-item>
              </a-form>
          </template>
      </commpVxeTable>
      <register ref="registerRef" :processingData="processingData" @success="success" @reviseClick="reviseClick"/>
  </div>
</template>
<script>
import assessCheckApi from './service/api'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import blobType from '@/common/blobType'
import moment from 'moment'
import { initHcyNdkp, queryJobByJobId, deleteNdkpFlowJob } from './service/index'
import register from './register.vue'
export default {
  components:{
      commpVxeTable,
      register,
  },
  props:{
      fywflcode:{
          type:String,
          default:'',
          required:false,
      },
      linkName:{
          type:String,
          default:'',
          required:false,
      }
  },
  data(){
      return{
          processingData:{},
          fyearForm:this.$form.createForm(this, { name: 'formNmae' }),
          fyear:moment(new Date()).format('YYYY'),
          formItem:[
              {
                  label: '年度',
                  model: 'fsxmc',
              },{
                  label: '姓名',
                  model: 'fusermc',
              },{
                  label: '工作单位',
                  model: 'fgzdw',
              }

          ],
          columnsVxe:[
          {
              type: 'checkbox',
              width: 60 ,
              fixed: 'left'
          },{
              title: '姓名', //列头显示文字
              field: 'fusermc',
              width: 100,
              titleInterval:true,
              slots: {
              // 使用插槽模板渲染
                  header:'data1_header',
                  default:'operation_ffsrmc',
              },
          },{
              title: '工作单位',
              field: 'fgzdw',
          },{
              title: '年度',
              field: 'fyear',
              width: 100,
              titleInterval:true,
              slots: {
              // 使用插槽模板渲染
                  header:'data2_header',
              },
          },{
              title: '总结时间',
              field: 'fzjjssj',
              width: 250,
              slots: {
              // 使用插槽模板渲染
                  default: 'name_fzjjssj',
              },
          },{
              title: '环节名称',
              field: 'fhjmc',
              width: 100,
          },{
              title: '发送人',
              field: 'fusermc',
              width: 100,
          },{
              title: '发送时间',
              field: 'ffssj',
              width: 250,
          },{
              title: '操 作',
              field: 'id',
              width: 150,
              slots: {
              // 使用插槽模板渲染
                  // header:'data_header',
                  default: 'operation_btn',
              },
          }],
          dataTableConfig:{
              api: assessCheckApi.list,
              rowId: 'jobid',
              fywflcode:this.fywflcode,
              paramet:{}
          },
          checkboxKey:[],
          jobidList:[],
          nextNode:''
      }
  },
  watch:{

  },
  mounted(){

  },
  methods:{
      success(){
          this.$refs.acceptanceRegistrationRef.searchEvent()
          this.jobidList = []
          this.checkboxKey = []
      },
      searchEvent(){//搜索
          this.dataTableConfig.paramet = {
              ...this.dataTableConfig.paramet,
          }
          //console.log(this.dataTableConfig.paramet)
      },
      resetEvent(){//重置
          this.dataTableConfig.paramet = {
              ...this.dataTableConfig.paramet,
              fzjkssj:'',
              fzjjssj:'',
          }

      },
      checkboxChange(val){
          //console.log('选择项',val)
          this.checkboxKey = []
          this.jobidList = []
          this.nextNode = ''
          if(val.length){
              val.forEach(item => {
                  this.checkboxKey.push(item.ndkpid)
                  this.jobidList.push(item.jobid)
              });
              this.nextNode = val[0].fhjmc
          }


      },
      reviseClick(row){//办理
          //console.log(row)
          // processingData
          queryJobByJobId({jobid:row.jobid}).then(res=>{
              if(res.code == 200){
                  var data = res.result
                  var HandledByOptions = []
                  data.nextNodeDbrList.forEach(item => {
                          item = {
                              value:item.dbrid,
                              label:item.dbr
                          }
                          HandledByOptions.push(item)
                      });
                  this.processingData = {
                      fywflcode:this.fywflcode,
                      jobid:row.jobid,
                      fhjmc:data.job.fhjmc,
                      ndkpid:data.ndkp.id,
                      fsfcykp:data.ndkp.fsfcykp,
                      fusermc:data.ndkp.fusermc,
                      fgzdw:data.ndkp.fgzdw,
                      fdqssk:data.ndkp.fdqssk,
                      fyear:data.ndkp.fyear,
                      fljzlqk:data.ndkp.fljzlqk,
                      fsjjccs:data.ndkp.fsjjccs,
                      fzxxpcs:data.ndkp.fzxxpcs,
                      fcql:data.ndkp.fcql,
                      fcjjcqk:data.ndkp.fcjjcqk,
                      fcjjxjyqk:data.ndkp.fcjjxjyqk,
                      frcywnlkhqk:data.ndkp.frcywnlkhqk,
                      fgrndzjqk:data.ndkp.fgrndzjqk,
                      fndzhkpjg:data.ndkp.fndzhkpjg,
                      fbz:data.ndkp.fbz,
                      opinion:data.ndkp.opinion,
                      nextNode:data.nextNode,
                      dbrid:data.nextNodeDbrList.length?[data.nextNodeDbrList[0].dbrid]:[],
                      dbridList:HandledByOptions,
                      smgflag:false,
                      fthyj:data.job.fthyj,
                      fzjkssj:data.ndkp.fzjkssj,
                      fzjjssj:data.ndkp.fzjjssj,
                      fjcqyzs:data.ndkp.fjcqyzs,
                      fdrzycs:data.ndkp.fdrzycs,
                      fdrzzcs:data.ndkp.fdrzzcs,
                      fcjpscs:data.ndkp.fcjpscs,
                      fndszbg:data.ndkp.fndszbg,

                      frckhyxcs:data.ndkp.frckhyxcs,
                      frckhyxl:data.ndkp.frckhyxl,
                      frckhhgcs:data.ndkp.frckhhgcs,
                      frckhhgl:data.ndkp.frckhhgl,
                      frckhbhgcs:data.ndkp.frckhbhgcs,

                  }
                  this.$refs.registerRef.getData(this.processingData)
                  this.$refs.registerRef.visible = true
              }
          })
      },
  }
}
</script>
<style lang="less">
.vxe-fyear{
  padding-top: 0 !important;

}
.fyear-box{
  .ant-input-number{
      width: 105px !important;
  }
}
.red-btn{
  border: 1px solid #ed5565 !important;
  background-color: #ed5565 !important;
}
</style>
